home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / include / user / fs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-13  |  21.7 KB  |  647 lines

  1. /*
  2.  * fs.h --
  3.  *
  4.  *    Definitions and types used in the user's interface to
  5.  *    the filesystem.
  6.  *
  7.  * Copyright 1985, 1988, 1991 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that this copyright
  11.  * notice appears in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /r3/kupfer/spriteserver/include/user/RCS/fs.h,v 1.3 91/12/12 22:23:07 kupfer Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _FS_H
  20. #define _FS_H
  21.  
  22. #ifndef _MiG
  23. #include <mach.h>
  24. #include <spriteTime.h>
  25. #ifdef SPRITED
  26. #include <user/proc.h>
  27. #else
  28. #include <proc.h>
  29. #endif /* SPRITED */
  30. #endif /* _MiG */
  31.  
  32. /*
  33.  * The macros major and minor are defined in sys/types.h.  They are also
  34.  * the names of fields in a structure defined in fs.h.  Only gcc and ANSI
  35.  * C are clever enough to handle this.  (The field name isn't followed
  36.  * by an open paren...)  So, if you include this file and <sys/types.h>
  37.  * then you can use the major() and minor() macros.  However, <sys/types.h>
  38.  * also defines unix_major() and unix_minor, so you can use those.
  39.  */
  40. #ifndef __STDC__ 
  41. #ifdef major
  42. #undef    major
  43. #endif
  44. #ifdef minor 
  45. #undef    minor
  46. #endif 
  47. #endif /* ! __STDC__ */
  48.  
  49. /*
  50.  * Global constants.
  51.  * FS_BLOCK_SIZE - the size of filesystem blocks
  52.  * FS_MAX_PATH_NAME_LENGTH - the maximum length of a complete pathname.
  53.  * FS_MAX_NAME_LENGTH - is the maximum length of one component of a name.
  54.  */
  55. #define    FS_BLOCK_SIZE        4096
  56. #define FS_MAX_PATH_NAME_LENGTH    1024
  57. #define FS_MAX_NAME_LENGTH    255
  58.  
  59. /* 
  60.  * These constants are used to ensure that the MIG-generated size for a 
  61.  * type agrees with its actual size.
  62.  */
  63. #define FS_ATTRIBUTES_SIZE    28    /* ints in an Fs_Attributes */
  64. #define FS_DEVICE_SIZE        6    /* ints in an Fs_Device */
  65.  
  66. #ifndef _MiG
  67.  
  68.  
  69.  
  70. /*
  71.  * Open stream flags that are passed to Fs_Open from user programs.  These
  72.  *    flags are kept in a kernel data structure along with some other
  73.  *    flags used by the operating system internally.  This fact is only
  74.  *    important to pseudo-device and pseudo-file-system servers which
  75.  *    may see the other flags, which are defined in <kernel/fs.h>.
  76.  *
  77.  *    FS_READ        - open the file for read access.
  78.  *    FS_WRITE    - open the file for write access, can be combined
  79.  *              with FS_READ
  80.  *    FS_EXECUTE    - open the file for execute access.  This mode is used
  81.  *              by the kernel when opening a.out files.  It can
  82.  *              be used to limit the open to executables files.
  83.  *    FS_APPEND    - open for append mode. All writes get appended to the
  84.  *              end of the file regardless of the file pointer.
  85.  *    FS_CLOSE_ON_EXEC - close the stream when the process execs.
  86.  *    FS_NON_BLOCKING - I/O operations don't block (if applicable) but
  87.  *              instead return FS_WOULD_BLOCK.
  88.  *    FS_CREATE    - create the file if it doesn't exist.
  89.  *    FS_TRUNC    - truncate the file to zero length.
  90.  *    FS_EXCLUSIVE    - If specified with FS_CREATE the open/create will
  91.  *              fail if the file already exists.
  92.  *    FS_NAMED_PIPE_OPEN - Open as a named pipe. (NOT IMPLEMENTED)
  93.  *    FS_PDEV_MASTER     - Caller wants to be master of the pseudo-device.
  94.  *    FS_PFS_MASTER     - Caller wants to be server of the pseudo-filesystem.
  95.  */
  96. #define FS_USER_FLAGS              0xfff
  97. #define FS_READ                  0x001
  98. #define FS_WRITE              0x002
  99. #define FS_EXECUTE              0x004
  100. #define FS_APPEND              0x008
  101. #define FS_CLOSE_ON_EXEC        0x010
  102. #define FS_PDEV_MASTER            0x020
  103. #define FS_NAMED_PIPE_OPEN        0x040
  104. #define    FS_PFS_MASTER            0x080
  105. #define FS_NON_BLOCKING            0x100
  106. #define FS_CREATE              0x200
  107. #define FS_TRUNC              0x400
  108. #define FS_EXCLUSIVE              0x800
  109. /*            More high order bits are defined in <kernel/fs.h> !! */
  110.  
  111. /*
  112.  * Flags for Fs_Select:
  113.  *
  114.  *    FS_READABLE    - Does the stream have data that can be read?
  115.  *    FS_WRITABLE    - Can data be written to the stream?
  116.  *    FS_EXCEPTION    - Are there any exception conditions that have
  117.  *              raised for the stream? (e.g. out-of-band data).
  118.  */
  119.  
  120. #define FS_READABLE    FS_READ
  121. #define FS_WRITABLE    FS_WRITE
  122. #define FS_EXCEPTION    FS_EXECUTE
  123. #define FS_EXCEPTABLE    FS_EXCEPTION
  124.  
  125.  
  126.  
  127. /*
  128.  * The Fs_Attributes type is the information returned about a file
  129.  * from the Fs_GetAttributes and Fs_GetAttributesID system calls.
  130.  * This struct is also the input parameter for the Fs_SetAttributes
  131.  * and Fs_SetAttributesID system calls.
  132.  */
  133. typedef struct Fs_Attributes {
  134.     int    serverID;        /* Host ID of file server */
  135.     int domain;            /* Server-relative domain number of the file */
  136.     int fileNumber;        /* Domain-relative file number */
  137.     int type;            /* File types defined below */
  138.     int size;            /* Number of bytes in the file */
  139.     int numLinks;        /* Number of directory references to the file */
  140.     unsigned int permissions;    /* Permission bits defined below */
  141.     int uid;            /* User ID of file's owner */
  142.     int gid;            /* ID of file's owning group */
  143.     int devServerID;        /* ID of device server */
  144.     int devType;        /* Type of the device */
  145.     int devUnit;        /* Interpreted by the device driver */
  146.     Time createTime;        /* Time of the files creation */
  147.     Time accessTime;        /* Time of last access to the file */
  148.     Time descModifyTime;    /* Time the file descriptor was last modified */
  149.     Time dataModifyTime;    /* Time the file's data was last modified */
  150.     int  blocks;        /* The number of blocks taken by the file */
  151.     int  blockSize;        /* The size of each block */
  152.     int    version;        /* This is incremented when file is written */
  153.     int userType;        /* User defined file type */
  154.     int pad[4];            /* Reserved */
  155. } Fs_Attributes;
  156.  
  157. /*
  158.  * The following are values for the fileOrLink argument to Fs_Set/GetAttributes.
  159.  *    FS_ATTRIB_LINK    Get the attributes of the named link, not of the
  160.  *        file the link refers to.
  161.  *    FS_ATTRIB_FILE    Get the attributes of the name file.  If the last
  162.  *        component of the file name is a link then use the file
  163.  *        to which the link refers.
  164.  */
  165. #define FS_ATTRIB_LINK            1
  166. #define FS_ATTRIB_FILE            2
  167.  
  168. /*
  169.  * The following are values for the flags passed to Fs_SetAttr and Fs_SetAttrID
  170.  *    FS_SET_ALL_ATTRS - Attempt to set all settable attributes (see below)
  171.  *    FS_SET_TIMES    - Set data modify and file access times.
  172.  *    FS_SET_MODE    - Set the permission mode bits of the file.
  173.  *    FS_SET_OWNER    - Set the owner and group owner of a file.
  174.  *    FS_SET_FILE_TYPE - Set the user-defined file type of a file.
  175.  *    FS_SET_DEVICE    - Set device attributes - server, type, unit
  176.  */
  177. #define FS_SET_ALL_ATTRS    0x1F
  178. #define FS_SET_TIMES        0x01
  179. #define FS_SET_MODE        0x02
  180. #define FS_SET_OWNER        0x04
  181. #define FS_SET_FILE_TYPE    0x08
  182. #define FS_SET_DEVICE        0x10
  183.  
  184. /*
  185.  * FS_LOCALHOST_ID is used as the device server ID for generic devices,
  186.  * those expected to exist on all hosts.  It is also used in the kernel
  187.  * when the "ioServerID" is the local host.
  188.  */
  189. #define FS_LOCALHOST_ID        -1
  190.  
  191. /*
  192.  * File types kept in FsFileDescriptors on disk:
  193.  *    FS_FILE            ordinary disk file
  194.  *    FS_DIRECTORY        file used to implement the directory stucture
  195.  *    FS_SYMBOLIC_LINK    regular file used to implement links
  196.  *    FS_REMOTE_LINK        symbolic link used to mark the top of a domain
  197.  *    FS_DEVICE        Placeholder for peripheral device
  198.  *    FS_REMOTE_DEVICE    not used
  199.  *    FS_LOCAL_PIPE        Temporary half-duplex pipe
  200.  *    FS_NAMED_PIPE        Persistent half-duplex pipe (not implemented)
  201.  *    FS_PSEUDO_DEV        Full duplex communication to a user process
  202.  *    FS_PSEUDO_FS        Marks a domain controlled by a user process
  203.  *    FS_XTRA_FILE        Extra file type used to stage the
  204.  *                (re)implementation of standard file types
  205.  */
  206.  
  207. #define    FS_FILE                0
  208. #define    FS_DIRECTORY            1
  209. #define    FS_SYMBOLIC_LINK        2
  210. #define    FS_REMOTE_LINK            3
  211. #define    FS_DEVICE            4
  212. #define    FS_REMOTE_DEVICE        5
  213. #define    FS_LOCAL_PIPE            6
  214. #define    FS_NAMED_PIPE            7
  215. #define    FS_PSEUDO_DEV            8
  216. #define FS_PSEUDO_FS            9
  217. #define FS_XTRA_FILE            10
  218.  
  219.  
  220. /*
  221.  * User-defined file types.  A number of types are standardized, but others
  222.  * may be defined by the user.
  223.  *
  224.  *     FS_USER_TYPE_UNDEFINED        - no type set
  225.  *     FS_USER_TYPE_TMP              - temporary file
  226.  *     FS_USER_TYPE_SWAP             - swap file
  227.  *     FS_USER_TYPE_OBJECT           - ".o" file
  228.  *     FS_USER_TYPE_BINARY           - executable
  229.  *     FS_USER_TYPE_OTHER           - file that doesn't correspond to any
  230.  *                      specific type.  This is distinct from
  231.  *                      undefined, which says the type is
  232.  *                      uninitialized and may be inferred by
  233.  *                      parent directory or file name.
  234.  */
  235. #define FS_USER_TYPE_UNDEFINED  0
  236. #define FS_USER_TYPE_TMP        1
  237. #define FS_USER_TYPE_SWAP    2
  238. #define FS_USER_TYPE_OBJECT    3
  239. #define FS_USER_TYPE_BINARY    4
  240. #define FS_USER_TYPE_OTHER    5
  241.  
  242.  
  243. /*
  244.  * The Fs_FileID and Fs_UserIDs types are exported to user-level so that
  245.  * pseudo-filesystem servers can understand the arguments to lookup operations
  246.  * that are defined in fsNameOps.h
  247.  *
  248.  * Fs_FileID - Uniquely identify a filesystem object.  A type is the first
  249.  *    field, the hostID of the server is next, and the remaining fields 
  250.  *    are interpreted by the implementation of that type of filesystem object
  251.  *    (ie. files, devices, pipes, pseudo-devices, etc.)
  252.  *    A global hash table of filesystem objects, (called "handles")
  253.  *    is maintained with this Fs_FileID as the hash key.
  254.  */
  255. typedef struct Fs_FileID {
  256.     int        type;        /* Defined in kernel fsio.h (stream types).
  257.                  * Used in I/O switch, and implicitly
  258.                  * indicates what kind of structure follows
  259.                  * the FsHandleHeader in the Handle. */
  260.     int        serverID;    /* Host that controls the object.  (This would
  261.                  * have to be a multi-cast ID for objects
  262.                  * that support replication.) */
  263.     int        major;        /* First type specific identifier. */
  264.     int        minor;        /* Second type sepcific identifier. */
  265. } Fs_FileID;            /* 16 BYTES */
  266.  
  267. /*
  268.  *    The FS_NUM_GROUPS constant limits the number of group IDs that
  269.  *    are used even though the proc table supports a variable number.
  270.  */
  271. #define FS_NUM_GROUPS    8
  272.  
  273. typedef struct Fs_UserIDs {
  274.     int user;            /* Indicates effective user ID */
  275.     int numGroupIDs;        /* Number of valid entries in groupIDs */
  276.     int group[FS_NUM_GROUPS];    /* The set of groups the user is in */
  277. } Fs_UserIDs;            /* 40 BYTES */
  278.  
  279.  
  280.  
  281.  
  282. /*
  283.  * Generic IO Control operations.
  284.  *    IOC_REPOSITION        Reposition the current offset into the file.
  285.  *    IOC_GET_FLAGS        Return the flags associated with the stream.
  286.  *    IOC_SET_FLAGS        Set all the flags for the stream.
  287.  *    IOC_SET_BITS        Set some of the flags for the stream.
  288.  *    IOC_CLEAR_BITS        Clear some of the flags for the stream.
  289.  *    IOC_TRUNCATE        Truncate the stream to a given length.
  290.  *    IOC_LOCK        Lock the stream or underlying file.
  291.  *    IOC_UNLOCK        Unlock the stream.
  292.  *    IOC_NUM_READABLE    Return the number of bytes available.
  293.  *    IOC_GET_OWNER        Return the process or family that gets signals.
  294.  *    IOC_SET_OWNER        Set the process or family that gets signals.
  295.  *    IOC_MAP            Map the stream into the processes VM
  296.  *    IOC_PREFIX        Get the prefix under which the stream was
  297.  *                opened.  This is useful if a server is exporting
  298.  *                a domain under more than one name.  The getwd()
  299.  *                library call uses this feature.
  300.  *    IOC_WRITE_BACK        Write back any cached stream data.
  301.  *    IOC_MMAP_INFO        Provide server with information on
  302.  *                VM memory mapping.
  303.  *
  304.  *    IOC_GENERIC_LIMIT    This is the maximum IOC number that can be
  305.  *                used for the generic I/O controls supported
  306.  *                by the kernel.  Device drivers define I/O
  307.  *                control numbers above this limit.  This limit
  308.  *                is used in the kernel to optimize handling
  309.  *                generic vs. non-generic I/O controls.
  310.  */
  311.  
  312. #define    IOC_REPOSITION            1
  313. #define    IOC_GET_FLAGS            2
  314. #define IOC_SET_FLAGS            3
  315. #define IOC_SET_BITS            4
  316. #define IOC_CLEAR_BITS            5
  317. #define IOC_TRUNCATE            6
  318. #define IOC_LOCK            7
  319. #define IOC_UNLOCK            8
  320. #define IOC_NUM_READABLE        9
  321. #define IOC_GET_OWNER            10
  322. #define IOC_SET_OWNER            11
  323. #define IOC_MAP                12
  324. #define IOC_PREFIX            13
  325. #define IOC_WRITE_BACK            14
  326. #define    IOC_MMAP_INFO            15
  327. #define IOC_GENERIC_LIMIT        ((1<<16)-1)
  328.  
  329. /*
  330.  * Maximum number of bytes that be copied in on an iocontrol.
  331.  */
  332.  
  333. #define    IOC_MAX_BYTES    4096
  334.  
  335.  
  336. /*
  337.  * IOC_REPOSITION - reposition the file access position.
  338.  */
  339.  
  340. typedef struct Ioc_RepositionArgs {
  341.     int base;    /* Base at which to start reposition: defines below */
  342.     int offset;    /* Offset from base */
  343. } Ioc_RepositionArgs;
  344.  
  345. /*
  346.  * Base argument definitions:
  347.  *    IOC_BASE_ZERO        base is the beginning of the file.
  348.  *    IOC_BASE_CURRENT    base is the current position in the file.
  349.  *    IOC_BASE_EOF        base is the end of the file.
  350.  */
  351.  
  352. #define IOC_BASE_ZERO        0
  353. #define IOC_BASE_CURRENT    1
  354. #define IOC_BASE_EOF        2
  355.  
  356.  
  357.  
  358. /*
  359.  *    IOC_GET_FLAGS        Return the flags associated with the stream.
  360.  *    IOC_SET_FLAGS        Set all the flags for the stream.
  361.  *    IOC_SET_BITS        Set some of the flags for the stream.
  362.  *    IOC_CLEAR_BITS        Clear some of the flags for the stream.
  363.  *
  364.  *    A few of the low order bits in the flags field are reserved
  365.  *    for use by the kernel.  The rest bits are left for interpretation
  366.  *    by the (pseudo) device driver.
  367.  *        IOC_APPEND    Do append mode writes to the stream
  368.  *        IOC_NON_BLOCKING Do not block if I/O is not ready
  369.  *        IOC_ASYNCHRONOUS Dispatch I/O and signal when complete
  370.  *                 This is not implemented yet, 6/87
  371.  *        IOC_CLOSE_ON_EXEC This forces the stream to be closed when
  372.  *                the process execs another program.
  373.  *        IOC_READ    Stream is open for reading.
  374.  *        IOC_WRITE    Stream is open for writing.
  375.  */
  376.  
  377. #define IOC_GENERIC_FLAGS    0xFF
  378. #define    IOC_APPEND        0x01
  379. #define IOC_NON_BLOCKING    0x02
  380. #define IOC_ASYNCHRONOUS    0x04
  381. #define IOC_CLOSE_ON_EXEC    0x08
  382. #define IOC_READ        0x10
  383. #define IOC_WRITE        0x20
  384.  
  385.  
  386. /*
  387.  *    IOC_LOCK        Lock the stream or underlying file.
  388.  *    IOC_UNLOCK        Unlock the stream.
  389.  */
  390. typedef struct Ioc_LockArgs {
  391.     int        flags;        /* IOC_LOCK_EXCLUSIVE, no other locks allowed
  392.                  * IOC_LOCK_SHARED, can have many of these,
  393.                  *    but no exclusive locks 
  394.                  * IOC_LOCK_NO_BLOCK, don't block if the lock
  395.                  *    can't be obtained, return FS_WOUD_BLOCK
  396.                  */
  397.     /*
  398.      * The following fields are set by the kernel and used by
  399.      * lower levels to notify when the lock is obtainable.  Pseudo-device
  400.      * masters use IOC_PDEV_LOCK_READY IOControl to do this notify.
  401.      */
  402.     int        hostID;        /* Set by the kernel */
  403.     Proc_PID    pid;        /* Set by the kernel */
  404.     int        token;        /* Set by the kernel */
  405. } Ioc_LockArgs;
  406.  
  407. #define IOC_LOCK_SHARED            0x1
  408. #define IOC_LOCK_EXCLUSIVE        0x2
  409. #define IOC_LOCK_NO_BLOCK        0x8
  410.  
  411. /*
  412.  *    IOC_GET_OWNER        Return the process or family that gets signals.
  413.  *    IOC_SET_OWNER        Set the process or family that gets signals.
  414.  */
  415. typedef struct Ioc_Owner {
  416.     Proc_PID    id;        /* Process or Family ID */
  417.     int        procOrFamily;    /* IOC_OWNER_FAMILY or IOC_OWNER_PROC */
  418. } Ioc_Owner;
  419.  
  420. #define IOC_OWNER_FAMILY    0x1
  421. #define IOC_OWNER_PROC        0x2
  422.  
  423. /*
  424.  *    IOC_MAP            Map the stream into the processes VM
  425.  */
  426. typedef struct Ioc_MapArgs {
  427.     int        numBytes;
  428.     Address    address;
  429. } Ioc_MapArgs;
  430.  
  431. /*
  432.  *    IOC_PREFIX        Return prefix under which stream was opened.
  433.  */
  434. typedef struct Ioc_PrefixArgs {
  435.     char    prefix[FS_MAX_PATH_NAME_LENGTH];  /* Set by kernel */
  436. } Ioc_PrefixArgs;
  437.  
  438. /*
  439.  *    IOC_WRITE_BACK        Write back the cached data of a file.
  440.  *                Although the arguments are in terms
  441.  *                of bytes, the cache will block align
  442.  *                the write-back so the bytes are fully
  443.  *                included in the blocks written back.
  444.  */
  445. typedef struct Ioc_WriteBackArgs {
  446.     int        firstByte;    /* Index of first byte to write back */
  447.     int        lastByte;    /* Index of last byte to write back */
  448.     Boolean    shouldBlock;    /* If TRUE, call blocks until write back done */
  449. } Ioc_WriteBackArgs;
  450.  
  451. /*
  452.  *    IOC_MMAP_INFO        Give information to the server that a
  453.  *                client is mapping a stream into memory.
  454.  */
  455. typedef struct Ioc_MmapInfoArgs {
  456.     int        isMapped;    /* 1 if mapping, 0 if unmapping. */
  457.     int        clientID;    /* ID of the requesting client. */
  458. } Ioc_MmapInfoArgs;
  459.  
  460. /*
  461.  * A mask of 9 permission bits is used to define the permissions on a file.
  462.  * A mask like this occurs in the FileDescriptor for a file.  A mask like
  463.  * this is also part of the state of each process.  It defines the maximal
  464.  * set of permissions that a newly created file can have. The following
  465.  * define the various permission bits.
  466.  *    FS_OWNER_{READ|WRITE|EXEC}    A process with a UID that matches the
  467.  *            file's UID has {READ|WRITE|EXEC} permission on the file.
  468.  *    FS_GROUP_{READ|WRITE|EXEC}    A process with one of its group IDS
  469.  *            that matches the file's GID has permission...
  470.  *    FS_WORLD_{READ|WRITE|EXEC}    Any process has permission if WORLD
  471.  *            permission bits are set.
  472.  */
  473. #define FS_OWNER_READ            00400
  474. #define FS_OWNER_WRITE            00200
  475. #define FS_OWNER_EXEC            00100
  476. #define FS_GROUP_READ            00040
  477. #define FS_GROUP_WRITE            00020
  478. #define FS_GROUP_EXEC            00010
  479. #define FS_WORLD_READ            00004
  480. #define FS_WORLD_WRITE            00002
  481. #define FS_WORLD_EXEC            00001
  482.  
  483. /*
  484.  * Other permission bits:
  485.  *    FS_SET_UID    This bit set on a program image or shell script
  486.  *        causes the execed process to take on the user id of
  487.  *        the file.  (Thanks to Dennis Ritchie for this great idea.)
  488.  *    FS_SET_GID    As above, but for the group id.
  489.  */
  490. #define FS_SET_UID            04000
  491. #define FS_SET_GID            02000
  492.  
  493.  
  494.  
  495. /*
  496.  * Values of the mode argument to the Fs_CheckAccess system call.
  497.  *    FS_EXISTS    does the file exists (can the caller see it)
  498.  *    FS_READ        does the caller have read access
  499.  *    FS_WRITE    does the caller have write access
  500.  *    FS_EXECUTE    does the caller have execution access
  501.  */
  502. #define FS_EXISTS        0x0
  503.  
  504. /*
  505.  * Flag to Fs_GetNewID call that says choose any new stream ID.
  506.  */
  507. #define FS_ANYID            -1
  508.  
  509. /*
  510.  * The Fs_AttachDisk system call takes flags that affect just what is
  511.  * done with the disk partition and the associated prefix.
  512.  *    FS_ATTACH_READ_ONLY    Set the disk up to be read only.
  513.  *    FS_DETACH        The disk becomes inaccessible.  Any modified
  514.  *                filesystem data is flushed first.
  515.  *    FS_ATTACH_LOCAL        The disk is attached locally and not exported
  516.  *    FS_DEFAULT_DOMAIN    The domain is being attached by the kernel
  517.  *                during boot as the default.
  518.  *
  519.  */
  520. #define FS_ATTACH_READ_ONLY        0x1
  521. #define FS_DETACH            0x2
  522. #define FS_ATTACH_LOCAL            0x4
  523. #define FS_DEFAULT_DOMAIN        0x8
  524.  
  525. typedef struct Fs_TwoPaths {
  526.     int        pathLen1;    /* Length of the first path, including null */
  527.     int        pathLen2;    /* Length of the second path, including null */
  528.     char     *path1;        /* First pathname */
  529.     char     *path2;        /* Second pathname */
  530. } Fs_TwoPaths;
  531.  
  532. /*
  533.  * Information about a file system domain (volume).
  534.  */
  535. typedef struct {
  536.     int    maxKbytes;        /* Total Kbytes in the domain.  The allocation
  537.                  * routine might reserve some (%10) of this */
  538.     int    freeKbytes;        /* The number of available blocks.  This
  539.                  * reflects any reservations made by the
  540.                  * allocator.  If this is positive, blocks
  541.                  * are available. */
  542.     int    maxFileDesc;        /* The total number of files that can be
  543.                  * created in the domain. */
  544.     int    freeFileDesc;        /* The number of free file descriptors */
  545.     int blockSize;        /* Bytes per block */
  546.     int optSize;        /* Optimal transfer size, in bytes */
  547. } Fs_DomainInfo;
  548.  
  549.  
  550. /*
  551.  * User visible prefix table entry.  This is used by the routine that
  552.  * copies individual entries out to user programs.
  553.  */
  554. #define FS_USER_PREFIX_LENGTH    64
  555. #define FS_NO_SERVER        0
  556. typedef struct Fs_Prefix {
  557.     int serverID;        /* From FsFileID of prefix, FS_NO_SERVER if 
  558.                  * no handle */
  559.     int domain;            /* ditto */
  560.     int fileNumber;        /* ditto */
  561.     int version;        /* ditto */
  562.     int flags;            /* Defined below */
  563.     char prefix[FS_USER_PREFIX_LENGTH];
  564.     Fs_DomainInfo domainInfo;    /* Information about the domain. */
  565. } Fs_Prefix;
  566.  
  567. #ifndef FS_EXPORTED_PREFIX
  568. #define    FS_EXPORTED_PREFIX        0x1
  569. #define    FS_IMPORTED_PREFIX        0x2
  570. #define    FS_LOCAL_PREFIX            0x4
  571. #endif
  572.  
  573.  
  574. /*
  575.  * The Fs_ReadVector and Fs_WriteVector system calls take an array of
  576.  * I/O vectors. This allows data to be read to or written from non-contiguous
  577.  * areas of memory.
  578.  */
  579. typedef struct {
  580.     int        bufSize;    /* Size in bytes of the buffer */
  581.     Address    buffer;        /* For Fs_WriteVector, data to be written.
  582.                  * For Fs_ReadVector, place where read data 
  583.                  * is stored. */
  584. } Fs_IOVector;
  585.  
  586.  
  587. /*
  588.  * The structure below is use for creating devices with Fs_MakeDevice.
  589.  * It's also used internally by the kernel to hold the information passed
  590.  * to device specific routines so they can operate on their particular device.
  591.  */
  592. typedef struct Fs_Device {
  593.     int        serverID;    /* The host ID of the server that controls
  594.                  * the device. */
  595.     int        type;        /* The type of device.  This field is used to
  596.                  * index into an operation switch */
  597.     int        unit;        /* Type dependent unit specification. The
  598.                  * interpretation is up to the device driver */
  599.     /* 
  600.      * The rest of these fields are used only by the Sprite server.
  601.      */
  602.     mach_port_t    devPort;    /* handle returned by device_open */
  603.     mach_port_t mmapPort;    /* memory object returned by device_map */
  604.     ClientData    data;        /* Device type dependent data. This can be set
  605.                  * during the device open routine and should
  606.                  * be cleaned up in the device close routine. */
  607. } Fs_Device;
  608.  
  609. /*
  610.  * Definitions for the FS dispatcher library.
  611.  */
  612. typedef ClientData Fs_TimeoutHandler;
  613.  
  614. /* 
  615.  * Definitions for MIG-generated stubs.
  616.  */
  617. typedef char Fs_PathName[FS_MAX_PATH_NAME_LENGTH];
  618.  
  619. extern void            Fs_Dispatch();
  620. extern void            Fs_EventHandlerCreate();
  621. extern void             Fs_EventHandlerDestroy();
  622. extern ClientData         Fs_EventHandlerData();
  623. extern ClientData         Fs_EventHandlerChangeData();
  624. extern char            *Fs_GetTempName();
  625. extern int            Fs_GetTempFile();
  626. extern int                  Fs_IOControl();
  627. extern Boolean            Fs_IsATerm();
  628. extern Fs_TimeoutHandler    Fs_TimeoutHandlerCreate();
  629. extern void             Fs_TimeoutHandlerDestroy();
  630.  
  631. extern int                  Ioc_ClearBits();
  632. extern int                  Ioc_GetFlags();
  633. extern int                  Ioc_GetOwner();
  634. extern int                  Ioc_Lock();
  635. extern int                  Ioc_Map();
  636. extern int                  Ioc_NumReadable();
  637. extern int                  Ioc_SetBits();
  638. extern int                  Ioc_Reposition();
  639. extern int                  Ioc_SetFlags();
  640. extern int                  Ioc_SetOwner();
  641. extern int                  Ioc_Truncate();
  642. extern int                  Ioc_Unlock();
  643. extern int                  Ioc_WriteBack();
  644.  
  645. #endif /* _MiG */
  646. #endif /* _FS_H */
  647.